﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CtpGglPlaces.Impl
{
    public class AttrBaseObj: JsonObject
    {
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            this.WriteJson(sb);
            return sb.ToString();
        }

        public String attribteGet(string key)
        {
            foreach (nvpair nvp in this.NameValuePair)
            {
                if (nvp.Name == key)
                {
                    return nvp.Value.ToString();
                }
            }
            return null;
        }

        public void attributeSet(string key, string value)
        {
            bool found = false;
            foreach (nvpair nvp in this.NameValuePair)
            {
                if (nvp.Name == key)
                {
                    nvp.Value = value;
                    found = true;
                }
            }
            if (!found)
            {
                this.NameValuePair.Add(new nvpair() { Name = key, Value = value });
            }
        }
    }
}
